 /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package settings.collections;

import settings.collections.elements.SettingsManager;
import settings.collections.elements.EType;
import java.util.ArrayList;

/**
 *
 * @author rbs
 */
public class ETypeCollection extends SettingsManager {

    private ArrayList<EType> eTypes;

    public ETypeCollection() {
        super("eTypes");
        eTypes = new ArrayList<EType>();
    }
    
    
    
    public void addEType(EType eType)
    {
        eTypes.add(eType);
    }
    
    public EType getEType(int id)
    {
        for (EType eType: eTypes)
            if (eType.getId() == id)
                return eType;
        return null;    
    }
    
    public Boolean delEType(int id)
    {
        
        EType type = getEType(id);
        
        if (type != null)
        {
            eTypes.remove(type);
            for (EType type2: eTypes)
                if (type2.getId() > id)
                    type2.setId(type2.getId() - 1);

            return true;
        }
        else
            return false; 
    }
    
    public void changeEType(EType old_eType, EType new_eType)
    {
        eTypes.set(old_eType.getId(), new_eType);
        System.out.println("EType Changed: " + new_eType.getName());
    }

    public ArrayList<EType> getETypes() {
        return eTypes;
    }
    
    
}
